/**
 * Attributes
 * 
 * 30/10/2013
 * 
 * Copyright GPL
 */
package com.jtmproject.struts.tulebox;

import com.jtmproject.struts.tulebox.classes.CheckValues;
import com.opensymphony.xwork2.ActionSupport;

/**
 * this class is an action to check the data insert by the user 
 * in Attributes.jsp
 * 
 * @author Javier Tejedor
 */
public class Attributes extends ActionSupport {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 6877652132877515905L;
	private static final int TOTAL_VALUE = 30;
	
	private int strength; 
	private int	intelligence; 
	private int ability;
	
	private String calculate;
	private String result;

	/**
	 * this is the default method to execute
	 */
	@Override
	public String execute() {

		if(new CheckValues().checkAdditionArrayValues(
				new int[]{strength, intelligence, ability}, TOTAL_VALUE)){

			result = getText("sumOk");
		}else{
			result = getText("sumNotOk");	
		}
		
		return SUCCESS;
	}
	
	/**
	 * this returns the result
	 * @return
	 */
	public String getResult() {
		return result;
	}

	/**
	 * this sets the result
	 * @param result
	 */
	public void setResult(String result) {
		this.result = result;
	}

	/**
	 * this returns the strength
	 * @return
	 */
	public int getStrength() {
		return strength;
	}

	/**
	 * this sets the strength
	 * @param strenght
	 */
	public void setStrength(int strength) {
		this.strength = strength;
	}

	/**
	 * this returns the intelligence
	 * @return
	 */
	public int getIntelligence() {
		return intelligence;
	}

	/**
	 * this sets the intelligence
	 * @param intelligence
	 */
	public void setIntelligence(int intelligence) {
		this.intelligence = intelligence;
	}

	/**
	 * this returns the ability
	 * @return
	 */
	public int getAbility() {
		return ability;
	}

	/**
	 * this sets the ability
	 * @param ability
	 */
	public void setAbility(int ability) {
		this.ability = ability;
	}

	/**
	 * this returns the "calculate" String, for the translations
	 * @return
	 */
	public String getCalculate() {
		return calculate;
	}

	/**
	 * this sets the "calculate" String, for the translations
	 * @param calculate
	 */
	public void setCalculate(String calculate) {
		this.calculate = calculate;
	}

	/**
	 * this method is called the first time that the user call Dice.jsp
	 */
	@Override
	public String input() throws Exception{
		return super.input();
	}
	
}
